import type { DataType } from "@/types/response";
import type { AxiosResponse } from "axios";

class ResUtil {
  static isSuccess(res: AxiosResponse<any, any>): boolean {
    return (res.data as DataType<any>).code == 200;
  }
  static getData<T>(res: AxiosResponse<any, any>): T {
    if( res.data.code !== 200){
      return null;
    }
    return (res.data as DataType<any>).data;
  }
  static getMessage(res: AxiosResponse<any, any>) {
    return (res.data as DataType<any>).message;
  }
}
export default ResUtil;
